package cn.tang.tframe.sdm.aop.handler;

import cn.tang.tframe.common.utils.ToStringUtil;
import org.aspectj.lang.ProceedingJoinPoint;
import org.slf4j.Logger;

import java.lang.reflect.Method;

/**
 * Created by tanghc on 17/1/18.
 */
public class AopLogExceptionHandler extends ExceptionHandler {
	private String keyword;
	private Logger logger;

	public AopLogExceptionHandler(String keyword, Logger logger){
		this.keyword = keyword;
		this.logger = logger;
	}
	@Override
	protected boolean doExceptionHandler(Exception e,ProceedingJoinPoint pjp, Object[] args, Method method, String className) {
		String argStr = ToStringUtil.reflectionToString(args, 50, 1024);
		logger.error("!!!!  {}  {} {} exception: param={}", new Object[] { keyword, className, method.getName(), argStr,
				e });
		return true;
	}
}
